﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ScormModel;

namespace WpfELearningAuthoringTool
{
    /// <summary>
    /// Interaction logic for SequencingOptionDialog.xaml
    /// </summary>
    public partial class SequencingOptionDialog : Window
    {
        RibbonBarRegion.RibbonBarHeader parentChild;
        ImsManifest imsmanifest;
        private Item selectedItem;
        public SequencingOptionDialog()
        {
            InitializeComponent();
        }
        public Item SelectedItem
        {
            get { return this.selectedItem; }
            set { this.selectedItem = value; }
        }
        public ImsManifest Imsmanifest
        {
            get { return this.imsmanifest; }
            set { this.imsmanifest = value; }
        }
        public RibbonBarRegion.RibbonBarHeader ParentChild
        {
            get { return this.parentChild; }
            set { this.parentChild = value; }
        }
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (rbAddNew.IsChecked == true)
            {
                if (selectedItem.Sequencing == null)
                {
                    SequencingConfiguration se = new SequencingConfiguration();
                    se.Imsmanifest = imsmanifest;
                    se.Owner = parentChild;
                    se.IsAddNew = true;
                    se.SelectedItem = selectedItem;
                    se.ShowDialog();
                }
                else
                {
                    SequencingConfiguration se = new SequencingConfiguration(selectedItem, imsmanifest);
                    se.Owner = parentChild;
                    se.IsAddNew = true;
                    se.ShowDialog();
                }
                Close();
            }
            else if (rbSequencingCollection.IsChecked == true)
            {
                //add them tree view info to get selected item
                SequencingCollectionDialog scd = new SequencingCollectionDialog(imsmanifest, selectedItem);
                scd.Owner = parentChild;
                scd.ShowDialog();
                Close();
            }
            else {
                MessageBox.Show("Please select sequencing option");
                return;
            }
            
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
